<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //剩余参数
        let obj = {
            name: "twj",
            age: 100,
            location: "changsha"
        }
        let { name, ...other } = obj
        console.log(name, other) //{age: 100, location: 'changsha'}
        function test(name, ...other) {
            console.log(name, other) //{name: 'twj', age: 100, location: 'changsha'}
        }
        test(obj)
        //...扩展运算符
        let obj1 = {
            name: "twj",
            location: "changsha"
        }
        let obj2 = {
            name: "xiaoming",
            age: 100
        }
        let obj3 = { ...obj1, ...obj2 } //后来者居上
        console.log(obj3) //{name: 'xiaoming', location: 'changsha', age: 100}
        //浅拷贝
        let obj5 = {
            name: "twj",
            age: 200
        }
        let obj6 = { ...obj5 }
        console.log(obj6) //{name: 'twj', age: 200}
    </script>
</body>

</html>